from pydantic_settings import BaseSettings


class Settings(BaseSettings):
    # 数据库配置
    DB_HOST: str = "localhost"
    DB_PORT: int = 3306
    DB_USER: str = "root"
    DB_PASSWORD: str = "1234"
    DB_NAME: str = "xiaohongshu_db"
    
    # Redis 配置
    REDIS_HOST: str = "localhost"
    REDIS_PORT: int = 6379
    
    # 应用配置
    SECRET_KEY: str = "your-secret-key-here-change-in-production"
    ALGORITHM: str = "HS256"
    ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 7  # Access Token有效期：7天
    REFRESH_TOKEN_EXPIRE_DAYS: int = 30  # Refresh Token有效期：30天
    
    # 容联云短信配置
    RONGLIAN_ACCOUNT_SID: str = "2c94811c9860a9c40198649f3bf10103"
    RONGLIAN_AUTH_TOKEN: str = "2628951731e649a891dd892fd88e8aea"
    RONGLIAN_APP_ID: str = "2c94811c9860a9c40198649f3dc3010a"
    RONGLIAN_TEMPLATE_ID: str = "1"  # 需要替换为实际的模板ID
    
    # 钉钉登录配置
    DINGTALK_APP_KEY: str = "dingsmy7vmfafwgedabz"
    DINGTALK_APP_SECRET: str = "6fvl2cAJiUr5L4omgiJzQRdmLAL4gbGEQPWm04_fhckQGSg3xaL7jHCfTuTeb6F7"
    
    # 百度 OCR API 配置
    ACCESS_KEY_ID: str = "HVkhAUt6x6QE59RLLOLs149C"
    ACCESS_KEY_SECRET: str = "zmAJ6cczvbyPPyvTNWuOQAseZowHzdnt"
    
    # RAG 配置
    DASHSCOPE_API_KEY: str = ""  # 通义千问 API Key，从环境变量获取或在此设置
    ES_HOST: str = "localhost"  # Elasticsearch 主机
    ES_PORT: int = 9200  # Elasticsearch 端口
    
    # Coze 配置
    COZE_API_TOKEN: str = "pat_hDtGtxX7ptWKcVwxHJSHnKtpY8Ttp7a1DE9Ttg3wQ4T5xMAlt9qP6W7NtBNryFg3"  # Coze API Token
    COZE_BOT_ID: str = "7570714659318284329"  # Coze Bot ID
    COZE_USE_CN_BASE: bool = True  # 是否使用中国区 API
    
    # MongoDB 配置（用于订单审计与库存快照）
    MONGODB_URI: str = "mongodb://121.196.221.125:27017"
    MONGODB_DB: str = "xiaohongshu_app"
    ORDER_AUDIT_COLLECTION: str = "order_audit_events"
    INVENTORY_SNAPSHOT_COLLECTION: str = "inventory_snapshots"
    MONGODB_USERNAME: str | None = "admin"
    MONGODB_PASSWORD: str | None = "123456"
    MONGODB_AUTH_SOURCE: str = "admin"
    
    # RabbitMQ 配置
    # ⚠️ 远程连接前提：必须在云服务器安全组开放 5672 端口（TCP入站规则）
    # 管理界面端口 15672 和 AMQP端口 5672 是不同的端口，需要分别开放
    RABBITMQ_HOST: str = "121.196.221.125"  # RabbitMQ 主机地址
    RABBITMQ_PORT: int = 5672  # RabbitMQ AMQP端口（管理端口是15672）
    RABBITMQ_USERNAME: str = "admin"  # RabbitMQ 用户名
    RABBITMQ_PASSWORD: str = "admin"  # RabbitMQ 密码
    
    class Config:
        env_file = ".env"


settings = Settings()

